package web.req;

import common.consts.Consts;
import common.consts.Ratings;
import common.validation.ValidationResult;
import org.hibernate.validator.constraints.NotBlank;
import web.Request;

import javax.validation.constraints.Min;

/**
 * Created by Administrator on 2015/7/3.
 */

public class RatingRequest extends Request {

    @Min(value = 1, message = Consts.i18nKey.INVALID_RECRUITMENT_ID)
    private long recruitment;

    @Min(value = 1, message = Consts.i18nKey.RATEE_IS_REQUIRED)
    private long ratee;

    @NotBlank(message = Consts.i18nKey.INVALID_RATE_VALUE)
    private String rate;

    private String comment;

    @Override
    public ValidationResult validate() {
        //扫描注解
        ValidationResult result = super.validate();
        if (!Ratings.isValid(rate)) {
            result.setSuccess(false);
            result.setMessage(Consts.i18nKey.INVALID_RATE_VALUE);
        }
        return result;
    }

    public long getRecruitment() {
        return recruitment;
    }

    public void setRecruitment(long recruitment) {
        this.recruitment = recruitment;
    }

    public long getRatee() {
        return ratee;
    }

    public void setRatee(long ratee) {
        this.ratee = ratee;
    }

    public String getRate() {
        return rate;
    }

    public void setRate(String rate) {
        this.rate = rate;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }
}
